from flask import Flask,render_template,request,abort

app = Flask(__name__)
# 场景:统一返回404不存在的页面.
# 使用:
@app.errorhandler(404)
def func_404(e):
    return render_template('d12_404.html'), 404

@app.errorhandler(ZeroDivisionError)
def func_404(e):
    return '0除错误'

@app.route('/')
def index():
    1/0
    name = request.args.get('name')
    if name == 'aaa':
        abort(404)
    return 'index'

if __name__ == '__main__':
    app.run(debug=True)